﻿using System;
using System.Collections.Generic;
using YJKRevitBase.Math;
using YJKRevitDimensionText.VerticalAutoDim.GeoModel;

namespace YJKRevitDimensionText.VerticalAutoDim.Comparer
{
	internal class GeoComparerWithSpotRule : IComparer<IPlanarGeo>
	{
		public GeoComparerWithSpotRule(bool bWeightOrWidth = true)
		{
			this.IsByWeight = bWeightOrWidth;
		}

		public int Compare(IPlanarGeo x, IPlanarGeo y)
		{
			double num;
			if (this.IsByWeight)
			{
				num = (double)(x.Weight - y.Weight);
			}
			else
			{
				num = x.Width - y.Width;
			}
			if (MathUtility.IsEqual(num, 0.0))
			{
				return 0;
			}
			if (MathUtility.LessThan(num, 0.0))
			{
				return 1;
			}
			return -1;
		}

		private bool IsByWeight = true;
	}
}
